// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import moment from 'moment';
import lodash from 'lodash';
import store from '@/utils/store'
import '@/directive/allow'
import '@/filter/index.js'
import './app.scss'
import './theme/element-variables.scss'
import 'babel-polyfill'


import {getStore} from './utils/storage'

router.beforeEach((to, from, next) => {
  /**
   * 以下情况会跳转到login页面
   * 1：当用户会话没有保存在本地，跳转（非html5页面 又 非login页面 ）时
   */
  if (!getStore('user_museum') && to.path != '/login' && !/^\/html5\//.test(to.path) ){
    next({name:'login'})
  }
  else {
    next()
  }
})

Vue.use(ElementUI)
Vue.prototype.$moment = moment;
Vue.prototype._=lodash


Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  store,
  el: '#app',
  router,
  components: {App},
  template: '<App/>'
})
